﻿using System.ComponentModel.Composition;
using YunBox2.Contracts.Core;

namespace YunBox2.Client.Infrastructure.ViewModels
{
    [Export]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class MyProfileViewModel : MainContentViewModel
    {
        [ImportingConstructor]
        public MyProfileViewModel()
        {
            ClientContext.Current.PropertyChanged += (s, e) =>
                                                         {
                                                             if (e.PropertyName == "CurrentUser")
                                                             {
                                                                 RaisePropertyChanged("Current");
                                                             }
                                                         };
        }

        public User Current
        {
            get
            {
                return ClientContext.Current.CurrentUser;
            }
        }

        [Import]
        public MyEmailEditorViewModel EmailEditorViewModel
        {
            get;
            private set;
        }

        [Import]
        public MyPasswordEditorViewModel PasswordEditorViewModel
        {
            get;
            private set;
        }

        public override string Title
        {
            get
            {
                return "用户信息管理";
            }
        }
    }
}